%Figure 3

%Panel A

clear all; close all;
para;
options = odeset('AbsTol',1e-13,'RelTol',1e-13);

%Solve Optimal Contract
OptContract;

SB;

Solve;

%Solve for beta_t for T=40 time periods
T=40;
Time;




 
 
 subplot(1,2,1); hold on
 plot(solVTime.x,smooth(vbetat,0.001), 'k', 'Linewidth',3);
 xlabel('$t$','Interpreter','latex')
 ylabel('$\beta_t$','Interpreter','latex')
 title('A: Retention Dynamics (Baseline Parameters)','Interpreter', 'LaTex', 'FontSize',13)
 axis tight;

%Panel B

clear all; 

para;
options = odeset('AbsTol',1e-13,'RelTol',1e-13);
gamma=0.18;
phi=11;

%Solve for the optimal contract
OptContract;

SB;

Solve;

%Length of time interval over which beta_t is plotted
T=2;

%Calculate beta_t
Time;



fFigure=figure(1); hold on;


 
 
  subplot(1,2,2); hold on
 plot(solVTime.x,smooth(vbetat,0.001), 'k', 'Linewidth',3);
 xlabel('$t$','Interpreter','latex')
 ylabel('$\beta_t$','Interpreter','latex')
    title('B: Retention Dynamics (Larger $\gamma$ and $\phi$)','Interpreter', 'LaTex', 'FontSize',13)
 axis tight;


 resize_plot(fFigure,11.75,2.5,13);


print('Impt','-depsc')